﻿<UserControl x:Class="SL_Drag_Drop.sucDragDropListbox3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:dragdrop="clr-namespace:SL_Drag_Drop_BaseClasses;assembly=SL_Drag_Drop_BaseClasses">
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" ></RowDefinition>
            <RowDefinition Height="Auto" ></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>


        <TextBlock Text="Dragging and dropping to a ListBox" 
                       FontSize="14" Margin="10"
                       HorizontalAlignment="Left" VerticalAlignment="Top"
                       Grid.ColumnSpan="2"></TextBlock>

        <TextBlock FontSize="11" TextWrapping="Wrap" Margin="10"
                       HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1"
                       Grid.ColumnSpan="2">
                <Run Text="This example demonstrates more features of the Drag and Drop Manager.  You can drag each item to the ListBox on your right.  Once it's dropped, it will be added to the list."></Run>
        </TextBlock>


        <Grid Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="80"></RowDefinition>
                <RowDefinition Height="80"></RowDefinition>
                <RowDefinition Height="80"></RowDefinition>
            </Grid.RowDefinitions>

            <dragdrop:DropTarget ShowHover="False">
                <dragdrop:DropTarget.Content>
                    <dragdrop:DragSource AllDropTargetsValid="True"
                                         ShowReturnToOriginalPositionAnimation="False"
                                         DropMode="ReturnDragSource" DragHandleMode="FullDragSource"
                                         Tag="EmptyBattery">

                        <Image Source="Images/battery_empty.png" HorizontalAlignment="Center"
                           VerticalAlignment="Center" Width="48" Height="48">
                        </Image>

                    </dragdrop:DragSource>
                </dragdrop:DropTarget.Content>
                <dragdrop:DropTarget.Ghost>
                    <Image Source="Images/battery_empty.png" HorizontalAlignment="Center"
                           VerticalAlignment="Center" Width="48" Height="48" Opacity="0.3">
                    </Image>
                </dragdrop:DropTarget.Ghost>
            </dragdrop:DropTarget>

            <dragdrop:DropTarget Grid.Row="1" ShowHover="False">
                <dragdrop:DropTarget.Content>
                    <dragdrop:DragSource AllDropTargetsValid="True"
                                         ShowReturnToOriginalPositionAnimation="False"
                                         DropMode="ReturnDragSource" DragHandleMode="FullDragSource"
                                         Tag="HalfBattery">

                        <Image Source="Images/battery_half.png" HorizontalAlignment="Center"
                           VerticalAlignment="Center" Width="48" Height="48">
                        </Image>

                    </dragdrop:DragSource>
                </dragdrop:DropTarget.Content>
                <dragdrop:DropTarget.Ghost>
                    <Image Source="Images/battery_half.png" HorizontalAlignment="Center"
                           VerticalAlignment="Center" Width="48" Height="48" Opacity="0.3">
                    </Image>
                </dragdrop:DropTarget.Ghost>
            </dragdrop:DropTarget>

            <dragdrop:DropTarget Grid.Row="2" ShowHover="False">
                <dragdrop:DropTarget.Content>
                    <dragdrop:DragSource AllDropTargetsValid="True"
                                         ShowReturnToOriginalPositionAnimation="False"
                                         DropMode="ReturnDragSource" DragHandleMode="FullDragSource"
                                         Tag="FullBattery" >

                        <Image Source="Images/battery_full.png" HorizontalAlignment="Center"
                           VerticalAlignment="Center" Width="48" Height="48">
                        </Image>

                    </dragdrop:DragSource>
                </dragdrop:DropTarget.Content>
                <dragdrop:DropTarget.Ghost>
                    <Image Source="Images/battery_full.png" HorizontalAlignment="Center"
                           VerticalAlignment="Center" Width="48" Height="48" Opacity="0.3">
                    </Image>
                </dragdrop:DropTarget.Ghost>
            </dragdrop:DropTarget>


        </Grid>



        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Center" Grid.Row="2" Grid.Column="1" 
              >


            <dragdrop:DropTarget HorizontalAlignment="Center"
                                 DragSourceDropped="DropTarget_DragSourceDropped"  
                                 VerticalAlignment="Top" >
                <dragdrop:DropTarget.Content>
                    <dragdrop:DragSource DraggingEnabled="False">

                        <ListBox Width="160" Height="400" Loaded="itemsList_Loaded">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Width="150" Height="50" Background="#FF70BFF5">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="60" ></ColumnDefinition>
                                            <ColumnDefinition></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <Rectangle Grid.ColumnSpan="2" Stroke="Gray" StrokeThickness="1">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                    <GradientStop Color="#F9FFFFFF" Offset="0.267"/>
                                                    <GradientStop Color="#B2FFFFFF" Offset="0.53"/>
                                                    <GradientStop Color="Transparent" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <Image VerticalAlignment="Center" 
                                               HorizontalAlignment="Center"
                                               Source="{Binding ImageSrc}"></Image>
                                        <TextBlock Text="{Binding ItemText}" Grid.Column="1"
                                                   FontSize="14" VerticalAlignment="Center"></TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>

                    </dragdrop:DragSource>
                </dragdrop:DropTarget.Content>
            </dragdrop:DropTarget>
        </Grid>
     
    </Grid>
</UserControl>
